using System;
using DAL;
using Entities;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Text;

namespace BUS
{
    public class tbLoaiSanPhamBUS
    {
        public static void Insert(tbLoaiSanPhamEntities sanpham)
        {
            tbLoaiSanPhamDAL loaisanphamDAL = new tbLoaiSanPhamDAL();
            loaisanphamDAL.Insert(sanpham);
        }
        public static void Update(tbLoaiSanPhamEntities sanpham)
        {
            tbLoaiSanPhamDAL loaisanphamDAL = new tbLoaiSanPhamDAL();
            loaisanphamDAL.Update(sanpham);
        }
        public static void Delete(int iD)
        {
            tbLoaiSanPhamDAL loaisanphamDAL = new tbLoaiSanPhamDAL();
            loaisanphamDAL.Delete(iD);
        }
        public static tbLoaiSanPhamEntities.tbLoaiSanPhamEntitiesCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbLoaiSanPhamDAL loaisanphamDAL = new tbLoaiSanPhamDAL();
            return loaisanphamDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbLoaiSanPhamEntities.tbLoaiSanPhamEntitiesCollection GetAll()
        {
            int total = 0;
            tbLoaiSanPhamDAL loaisanphamDAL = new tbLoaiSanPhamDAL();
            return loaisanphamDAL.Get("where 1=1", 0, 0, tbLoaiSanPhamEntities.tbLoaiSanPhanEntitiesColumns.MaLoai.ToString(), "ASC", out total);
        }
        public static tbLoaiSanPhamEntities GetByID(int iD)
        {
            int total = 0;
            tbLoaiSanPhamDAL loaisanphamDAL = new tbLoaiSanPhamDAL();
            tbLoaiSanPhamEntities.tbLoaiSanPhamEntitiesCollection loaisanphamCollection = loaisanphamDAL.Get("where " + tbLoaiSanPhamEntities.tbLoaiSanPhanEntitiesColumns.MaLoai.ToString() + "=" + iD.ToString(), 0, 0, tbLoaiSanPhamEntities.tbLoaiSanPhanEntitiesColumns.MaLoai.ToString(), "ASC", out total);
            if (loaisanphamCollection.Count > 0)
                return loaisanphamCollection[0];
            return null;
        }
    }
}
